const express = require('express');
const router = express.Router();

router.get('/', (req, res) => {
    res.json({
        message: 'ok',
        payload: {
            content: [
                {
                    id: '1',
                    code: 'code1',
                    name: '政策1',
                    startDate: '2019-05-17T02:28:42.977Z',
                    status: 1,
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    remark: 'remark',
                    rowVersion: 'rowVersion',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ]
                },
                {
                    id: '2',
                    code: 'code2',
                    name: '政策2',
                    startDate: '2019-05-17T02:28:42.977Z',
                    status: 2,
                    dealerId: 'dealerId',
                    dealerCode: 'dealerCode',
                    dealerName: 'dealerName',
                    remark: 'remark2',
                    rowVersion: 'rowVersion2',
                    options: [
                        'update',
                        'abandon',
                        'enable'
                    ]
                }
            ],
            totalElements: 50
        }
    });
});

router.post('/import', (req, res) => {
    const data = [];
    for(let i = 1; i < 5; i++)
        data.push({
            id: `${i}`,
            vin: `vin-${i}`
        });
    res.json({
        message: 'ok',
        payload: {
            content: data
        }
    });
});
router.get('/:id', (req, res) => {
    res.json({
        message: '成功',
        payload: {
            id: 'id232',
            code: 'code233',
            name: 'name234',
            startDate: '2019-05-20T07:42:53Z',
            status: 1,
            remark: 'remark',
            dealerId: 'dealerId',
            dealerCode: 'dealerCode',
            dealerName: 'dealerName',
            creatorName: 'creatorName235',
            createTime: '2019-05-20T07:42:53Z',
            modifierName: 'modifierName236',
            modifyTime: '2019-05-20T07:42:53Z',
            abandonerName: 'abandonerName237',
            abandonTime: '2019-05-20T07:42:53Z',
            rowVersion: 'rowVersion',
            items: [
                {
                    id: 'id238',
                    type: 1,
                    warrantyDuration: 1,
                    warrantyMileage: 1,
                    remark: 'remark',
                    vehicleCategoryItems: [
                        {
                            id: 'id239',
                            productCategoryId: 'productCategoryId240',
                            productCategoryCode: 'productCategoryCode241',
                            productCategoryName: 'productCategoryName242',
                            vehicleProperty: 1,
                            partWarrantyCategories: [
                                {
                                    id: 'id243',
                                    code: 'code244',
                                    name: 'name245',
                                    remark: 'remark'
                                }, {
                                    id: 'id244',
                                    code: 'code245',
                                    name: 'name246',
                                    remark: 'remark1'
                                }
                            ],
                        }, {
                            id: 'id289',
                            productCategoryId: 'productCategoryId290',
                            productCategoryCode: 'productCategoryCode291',
                            productCategoryName: 'productCategoryName292',
                            vehicleProperty: 1,
                            partWarrantyCategories: [
                                {
                                    id: 'id293',
                                    code: 'code294',
                                    name: 'name295',
                                    remark: 'remark'
                                }
                            ],
                        },
                        {
                            id: 'id259',
                            productCategoryId: 'productCategoryId260',
                            productCategoryCode: 'productCategoryCode261',
                            productCategoryName: 'productCategoryName262',
                            vehicleProperty: 1,
                            partWarrantyCategories: [
                                {
                                    id: 'id263',
                                    code: 'code264',
                                    name: 'name265',
                                    remark: 'remark'
                                }, {
                                    id: 'id264',
                                    code: 'code265',
                                    name: 'name266',
                                    remark: 'remark1'
                                }
                            ],
                        }
                    ],
                    vehicleItems: []
                },
                {
                    id: 'id250',
                    type: 2,
                    warrantyDuration: 1,
                    warrantyMileage: 1,
                    remark: 'remark',
                    vehicleCategoryItems: [],
                    vehicleItems: [
                        {
                            vehicleId: 'vehicleId246',
                            vin: 'vin2',
                            parts: [
                                {
                                    id: 'id247',
                                    code: 'code248',
                                    name: 'name249',
                                    remark: 'remark',
                                },
                                {
                                    id: 'id248',
                                    code: 'code249',
                                    name: 'name250',
                                    remark: 'remark1',
                                }
                            ]
                        }, {
                            vehicleId: 'vehicleId286',
                            vin: 'vin8',
                            parts: [
                                {
                                    id: 'id287',
                                    code: 'code288',
                                    name: 'name289',
                                    remark: 'remark',
                                }
                            ]
                        }, {
                            vehicleId: 'vehicleId266',
                            vin: 'vin6',
                            parts: [
                                {
                                    id: 'id267',
                                    code: 'code268',
                                    name: 'name269',
                                    remark: 'remark',
                                },
                                {
                                    id: 'id268',
                                    code: 'code269',
                                    name: 'name20',
                                    remark: 'remark1',
                                }
                            ]
                        }
                    ]
                }
            ],
            options: [
                'update',
                'abandon',
                'enable'
            ]
        }
    });
});

router.post('/', (req, res) => {
    res.json({
        message: '成功'
    });
});

router.put('/:id', (req, res) => {
    res.json({
        message: '成功'
    });
});

router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '成功'
    });
});

router.put('/:id/enable', (req, res) => {
    res.json({
        message: '成功'
    });
});

module.exports = router;
